#include "gtkmarshalers.h"
#include "gtkimage.h"
#include "gtkbox.h"
-#include "deprecated/gtkstock.h"
#include "deprecated/gtkactivatable.h"
#include "gtksizerequest.h"
#include "gtktypebuiltins.h"
PROP_IMAGE,
PROP_RELIEF,
PROP_USE_UNDERLINE,
- PROP_USE_STOCK,
PROP_IMAGE_POSITION,
PROP_ALWAYS_SHOW_IMAGE,
P_("Text of the label widget inside the button, if the button contains a label widget"),
NULL,
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY);
-
+
props[PROP_USE_UNDERLINE] =
g_param_spec_boolean ("use-underline",
P_("Use underline"),
P_("If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key"),
FALSE,
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY);
-
- /**
- * GtkButton:use-stock:
- *
- * Deprecated: 3.10
- */
- props[PROP_USE_STOCK] =
- g_param_spec_boolean ("use-stock",
- P_("Use stock"),
- P_("If set, the label is used to pick a stock item instead of being displayed"),
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED);
-
+
props[PROP_RELIEF] =
g_param_spec_enum ("relief",
P_("Border relief"),
priv->constructed = FALSE;
priv->in_button = FALSE;
priv->button_down = FALSE;
- priv->use_stock = FALSE;
priv->use_underline = FALSE;
- priv->image_is_stock = TRUE;
priv->image_position = GTK_POS_LEFT;
priv->use_action_appearance = TRUE;
case PROP_USE_UNDERLINE:
gtk_button_set_use_underline (button, g_value_get_boolean (value));
break;
- case PROP_USE_STOCK:
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- gtk_button_set_use_stock (button, g_value_get_boolean (value));
- G_GNUC_END_IGNORE_DEPRECATIONS;
- break;
case PROP_IMAGE_POSITION:
gtk_button_set_image_position (button, g_value_get_enum (value));
break;
case PROP_USE_UNDERLINE:
g_value_set_boolean (value, priv->use_underline);
break;
- case PROP_USE_STOCK:
- g_value_set_boolean (value, priv->use_stock);
- break;
case PROP_IMAGE_POSITION:
g_value_set_enum (value, priv->image_position);
break;
iface->sync_action_properties = gtk_button_sync_action_properties;
}
-static void
-activatable_update_stock_id (GtkButton *button,
- GtkAction *action)
-{
- gboolean use_stock;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- use_stock = gtk_button_get_use_stock (button);
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- if (!use_stock)
- return;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- gtk_button_set_label (button, gtk_action_get_stock_id (action));
- G_GNUC_END_IGNORE_DEPRECATIONS;
-}
-
static void
activatable_update_short_label (GtkButton *button,
GtkAction *action)
{
GtkWidget *child;
GtkWidget *image;
- gboolean use_stock;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- use_stock = gtk_button_get_use_stock (button);
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- if (use_stock)
- return;
image = gtk_button_get_image (button);
GtkAction *action)
{
GtkWidget *image;
- gboolean use_stock;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- use_stock = gtk_button_get_use_stock (button);
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- if (use_stock)
- return;
image = gtk_button_get_image (button);
if (!priv->use_action_appearance)
return;
- if (strcmp (property_name, "stock-id") == 0)
- activatable_update_stock_id (GTK_BUTTON (activatable), action);
- else if (strcmp (property_name, "gicon") == 0)
+ if (strcmp (property_name, "gicon") == 0)
activatable_update_gicon (GTK_BUTTON (activatable), action);
else if (strcmp (property_name, "short-label") == 0)
activatable_update_short_label (GTK_BUTTON (activatable), action);
gtk_widget_show (GTK_WIDGET (activatable));
else
gtk_widget_hide (GTK_WIDGET (activatable));
-
+
gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
always_show_image = gtk_action_get_always_show_image (action);
G_GNUC_END_IGNORE_DEPRECATIONS
if (priv->use_action_appearance)
{
- activatable_update_stock_id (GTK_BUTTON (activatable), action);
activatable_update_short_label (GTK_BUTTON (activatable), action);
activatable_update_gicon (GTK_BUTTON (activatable), action);
activatable_update_icon_name (GTK_BUTTON (activatable), action);
{
GtkButtonPrivate *priv = button->priv;
GtkStyleContext *context;
- GtkStockItem item;
GtkWidget *child;
GtkWidget *label;
GtkWidget *box;
GtkWidget *image = NULL;
- gchar *label_text = NULL;
gint image_spacing;
context = gtk_widget_get_style_context (GTK_WIDGET (button));
"image-spacing", &image_spacing,
NULL);
- if (priv->image && !priv->image_is_stock)
+ if (priv->image)
{
GtkWidget *parent;
if (child)
gtk_container_remove (GTK_CONTAINER (button), child);
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (priv->use_stock &&
- priv->label_text &&
- gtk_stock_lookup (priv->label_text, &item))
- {
- if (!image)
- image = g_object_ref (gtk_image_new_from_stock (priv->label_text, GTK_ICON_SIZE_BUTTON));
-
- label_text = item.label;
- }
- else
- label_text = priv->label_text;
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
if (image)
{
priv->image = image;
else
gtk_box_pack_end (GTK_BOX (box), priv->image, FALSE, FALSE);
- if (label_text)
+ if (priv->label_text)
{
- if (priv->use_underline || priv->use_stock)
+ if (priv->use_underline)
{
- label = gtk_label_new_with_mnemonic (label_text);
+ label = gtk_label_new_with_mnemonic (priv->label_text);
gtk_label_set_mnemonic_widget (GTK_LABEL (label),
GTK_WIDGET (button));
}
else
- label = gtk_label_new (label_text);
+ label = gtk_label_new (priv->label_text);
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
return;
}
- if (priv->use_underline || priv->use_stock)
+ if (priv->use_underline)
{
label = gtk_label_new_with_mnemonic (priv->label_text);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button));
return button;
}
-/**
- * gtk_button_new_from_stock:
- * @stock_id: the name of the stock item
- *
- * Creates a new #GtkButton containing the image and text from a stock item.
- * Some stock ids have preprocessor macros like #GTK_STOCK_OK and
- * #GTK_STOCK_APPLY.
- *
- * If @stock_id is unknown, then it will be treated as a mnemonic
- * label (as for gtk_button_new_with_mnemonic()).
- *
- * Returns: a new #GtkButton
- *
- * Deprecated: 3.10: Use gtk_button_new_with_label() instead.
- */
-GtkWidget*
-gtk_button_new_from_stock (const gchar *stock_id)
-{
- return g_object_new (GTK_TYPE_BUTTON,
- "label", stock_id,
- "use-stock", TRUE,
- "use-underline", TRUE,
- NULL);
-}
-
/**
* gtk_button_new_with_mnemonic:
* @label: The text of the button, with an underscore in front of the
* @button: a #GtkButton
* @label: a string
*
- * Sets the text of the label of the button to @str. This text is
- * also used to select the stock item if gtk_button_set_use_stock()
- * is used.
+ * Sets the text of the label of the button to @str.
*
* This will also clear any previously set labels.
*/
return button->priv->use_underline;
}
-/**
- * gtk_button_set_use_stock:
- * @button: a #GtkButton
- * @use_stock: %TRUE if the button should use a stock item
- *
- * If %TRUE, the label set on the button is used as a
- * stock id to select the stock item for the button.
- *
- * Deprecated: 3.10
- */
-void
-gtk_button_set_use_stock (GtkButton *button,
- gboolean use_stock)
-{
- GtkButtonPrivate *priv;
-
- g_return_if_fail (GTK_IS_BUTTON (button));
-
- priv = button->priv;
-
- use_stock = use_stock != FALSE;
-
- if (use_stock != priv->use_stock)
- {
- priv->use_stock = use_stock;
-
- gtk_button_construct_child (button);
-
- g_object_notify_by_pspec (G_OBJECT (button), props[PROP_USE_STOCK]);
- }
-}
-
-/**
- * gtk_button_get_use_stock:
- * @button: a #GtkButton
- *
- * Returns whether the button label is a stock item.
- *
- * Returns: %TRUE if the button label is used to
- * select a stock item instead of being
- * used directly as the label text.
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_button_get_use_stock (GtkButton *button)
-{
- g_return_val_if_fail (GTK_IS_BUTTON (button), FALSE);
-
- return button->priv->use_stock;
-}
-
/**
* gtk_button_set_focus_on_click:
* @button: a #GtkButton
}
priv->image = image;
- priv->image_is_stock = (image == NULL);
gtk_button_construct_child (button);
* @button: a #GtkButton
*
* Gets the widget that is currenty set as the image of @button.
- * This may have been explicitly set by gtk_button_set_image()
- * or constructed by gtk_button_new_from_stock().
*
* Returns: (nullable) (transfer none): a #GtkWidget or %NULL in case
* there is no image
SIMPLE_ITEMS = 0,
FOCUS_ITEMS,
WRAPPY_ITEMS,
- STOCK_ITEMS,
IMAGE_ITEMS,
BUTTON_ITEMS
};
}
}
-static void
-populate_flowbox_stock (GtkFlowBox *flowbox)
-{
- GtkWidget *widget;
- static GSList *stock_ids = NULL;
- GSList *l;
- gint i;
-
- if (!stock_ids)
- {
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- stock_ids = gtk_stock_list_ids ();
- G_GNUC_END_IGNORE_DEPRECATIONS;
- }
-
- for (i = 0, l = stock_ids; i < 30 && l != NULL; i++, l = l->next)
- {
- gchar *stock_id = l->data;
- gchar *text = g_strdup_printf ("Item %02d", i);
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- widget = gtk_button_new_from_stock (stock_id);
- G_GNUC_END_IGNORE_DEPRECATIONS;
- gtk_widget_show (widget);
-
- g_object_set_data_full (G_OBJECT (widget), "id", (gpointer)g_strdup (text), g_free);
- gtk_container_add (GTK_CONTAINER (flowbox), widget);
- }
-}
-
static void
populate_flowbox_images (GtkFlowBox *flowbox)
{
populate_flowbox_focus (flowbox);
else if (items_type == WRAPPY_ITEMS)
populate_flowbox_wrappy (flowbox);
- else if (items_type == STOCK_ITEMS)
- populate_flowbox_stock (flowbox);
else if (items_type == IMAGE_ITEMS)
populate_flowbox_images (flowbox);
else if (items_type == BUTTON_ITEMS)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Simple");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Focus");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Wrappy");
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Stock");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Images");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Buttons");
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
gtk_widget_show (widget);
- gtk_widget_set_tooltip_text (widget, "Set the item's text orientation (cant be done for stock buttons)");
+ gtk_widget_set_tooltip_text (widget, "Set the item's text orientation");
gtk_box_pack_start (GTK_BOX (items_cntl), widget, FALSE, FALSE);
g_signal_connect (G_OBJECT (widget), "changed",